package Protocols.Test;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.SocketException;

public class Listener extends Thread {
	
	ObjectInputStream in;
	ObjectOutputStream out;
	TestClient parent;

	public Listener(TestClient parent, ObjectInputStream in, ObjectOutputStream out) {
		this.in=in;
		this.out=out;
		this.parent=parent;
	}
	
	public void run(){
		while (true){
			try {
				Object o= in.readObject();
				if (o instanceof String){
					String s= (String)o;
					System.out.println(">>>Message:  "+s);
				}
			}catch (SocketException e){
				System.out.println("Client: Verbindung zum Server getrennt");
				System.exit(0);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
